﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using myschoolDal;

namespace school
{
    public partial class manentercoursegrades : Form
    {
        private string term;
        private string major;
        private string source;
        private int score;
        private string name;

        public manentercoursegrades()
        {
            InitializeComponent();
        }

        private void textBox8_TextChanged(object sender, EventArgs e)
        {

        }

        private void textBox7_TextChanged(object sender, EventArgs e)
        {

        }

        private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            //if (comboBox2.SelectedItem != null && comboBox2.SelectedItem != null)
            //{

            //    foreach (DataRow row in stuservers.stugetallselectsouce(admin.loginId).Tables[0].Rows)
            //    {
            //        listBox1.Items.Add(row[0].ToString());
            //    }
            //}

        }

        private void comboBox2_SelectedIndexChanged(object sender, EventArgs e)
        {
            listBox1.Items.Clear();
            foreach (DataRow row in manserver.GetStuSourceLocation_Name(comboBox2.SelectedItem.ToString()).Tables[0].Rows)
            {
                listBox1.Items.Add(row[0].ToString());
            }
        }

        private void button1_Click(object sender, EventArgs e)
        {
            if (comboBox1.Text == "" || comboBox2.Text == "" || textBox2.Text == "" || listBox1.Text == "" || textBox3.Text == "")
            {
                MessageBox.Show("错误：" + bug.Class1.worng4001 + " \n错误代码：Wrong4001", "提示");
            }
            else
            {
                term = comboBox1.SelectedItem.ToString();
                major = comboBox2.SelectedItem.ToString();
                source = textBox2.Text.ToString();
                score = Convert.ToInt32(textBox3.Text);
                name = listBox1.SelectedItem.ToString();
                manserver.AddScores(name, term, major, source, score);
                MessageBox.Show("添加成功！", "提示");
            }

        }
    }
}
